//
//  WPForgotPasswordVC.m
//  wobingwoyi
//
//  Created by WGP on 16/8/2.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPForgotPasswordVC.h"
#import "NSString+Hash.h"

@interface WPForgotPasswordVC ()

@end
@implementation WPForgotPasswordVC

-(void)viewDidLoad
{
    [super viewDidLoad];
    
    self.titleLabel.text = @"找回密码";
    self.inviteCodeFieldView.hidden = YES;
    [self.registerBtn setTitle:@"完成" forState:UIControlStateNormal];
    CGRect frame = self.registerBtn.frame;
    frame.origin.y = frame.origin.y-4;
    self.registerBtn.frame = frame;
    
    self.registerView.passwordField.placeholder = @"输入新密码";
}


-(void)btnDidClick:(UIButton *)btn
{
    NSString *url = @"user/changePwd.do";
    NSDictionary *dict = @{@"account":self.registerView.phoneNumField.text,@"newPwd":[self.registerView.passwordField.text md5String],@"codeInput":self.registerView.verifyField.text};
    
    [[WPNetWorkManager sharedNetWorkManager] POST:url parameters:dict progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        if ([responseObject[@"result"] isEqualToString:@"success"])
        {
            NSDictionary *dictLogin = @{@"account":self.registerView.phoneNumField.text,@"password":[self.registerView.passwordField.text md5String]};
            [[WPUserAccountViewModel sharedInstance] globalLoginWith:dictLogin successHandle:^{
                
                //        登录成功
                [self showSuccessInfoWithStatus:@"登陆成功"];
    
                [self.view endEditing:YES];
                [self.navigationController dismissViewControllerAnimated:YES completion:nil];
                
            }];
        }
        else
        {
            [self showErrorInfoWithStatus:@"操作失败"];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        [self showErrorInfoWithStatus:@"网络错误"];
    }];
}



@end
